"""应用配置"""
from pydantic_settings import BaseSettings
from typing import List


class Settings(BaseSettings):
    """应用配置类"""
    
    # 应用信息
    APP_NAME: str = "CodeQualityBoard"
    APP_VERSION: str = "1.0.0"
    DEBUG: bool = False
    
    # 数据库
    DATABASE_URL: str
    
    # Celery
    CELERY_BROKER_URL: str = "db+postgresql://root@localhost:5432/qualityboard"
    CELERY_RESULT_BACKEND: str = "db+postgresql://root@localhost:5432/qualityboard"
    
    # 日志
    LOG_LEVEL: str = "INFO"
    
    # CORS (从环境变量读取，用逗号分隔)
    CORS_ORIGINS: str = "http://localhost:5173,http://localhost:3000"
    
    @property
    def cors_origins_list(self) -> List[str]:
        """将CORS_ORIGINS字符串转换为列表"""
        return [origin.strip() for origin in self.CORS_ORIGINS.split(",")]
    
    class Config:
        env_file = ".env"
        case_sensitive = True


settings = Settings()

